<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h2>在事件中调用</h2>
		<button onclick="hello()">调用hello()</button>
		<h2>在标签中调用</h2>
		<a href="javascript:hello();">调用hello()</a>
		<h2>带参数的函数</h2>
		<input type="text" id="input1"/>+
		<input type="text" id="input2"/><button onclick="calc()">=</button>
		<input type="text" id="input3"/>
		<script>
			//1.定义函数
			function hello()
			{
				console.log("Hello world!")
			}
			//带参数， 有返回值的函数
			function add(a,b)  // a b 形参
			{
				c = a+b;
				return c;
			}
			function calc()
			{
				num1 = parseInt(input1.value);
				num2 = parseInt(input2.value);
				input3.value = add(num1,num2); //num1num2 实参
			}
			//2.在script标签中调用函数
			hello();
			
			var add2 = function(a,b){
				return a+b;
			}

			vr add3 = new Function("a","b","return a+b")
			
			//练习1：
			
			
		</script>
		
		
	</body>
</html>
